# print ("你好，世界")
# print ('hello')
# msg = 'hello py !'
# print(msg)
# str = "abcdefg"  
# # print(str[0]) //a
# print(str[0:2])  // ab
# print(str[-1])   //g
# list = [ 'runoob', 786 , 2.23, 'john', 70.2 ]
# tinylist = [123, 'john']
# print(list[0])   //runoob
# print(list[1:])  //[786, 2.23, 'john', 70.2]
# print(tinylist) // [123, 'john']
# 数组 元组 == 只读列表
# tuple = ( 'runoob', 786 , 2.23, 'john', 70.2 )
# tinytuple = (123, 'john')
# print(tuple+tinytuple)
# 字典
# dict = {}
# dict['one'] = "This is one"
# dict[2] = "This is two"
# tinydict = {'name': 'runoob','code':6734, 'dept': 'sales'}
# print(dict['one'])        # 输出键为'one' 的值
# print(dict[2])             # 输出键为 2 的值
# print(tinydict)          # 输出完整的字典
# print(tinydict.keys())     # 输出所有键
# print(tinydict.values())   # 输出所有值

# 数据类型转换
# a = 21
# b = 10
# c = 0
# print(a%b)  # 1
# print(a//b)  # 2
# print(b**2)  # 100
# print(1/3)

# 赋值运算符
# a = 1
# b = 2
# c = 5
# c+=a
# print(c)
# b-=a
# print(b)
# b*=c
# print(b)
# c/=b
# print(c)
# b**=2
# print(b)
# c//=2
# print(c)
# 逻辑运算符
# a = 1
# b = 0
# print(a and b) # 0
# print(a or b) # 1
# print(not( a and b )) # True  not( a and b ) => !(a and b)
# print(not( a or b )) # False
# 成员运算符
 
# a = 10
# b = 20
# list = [1, 2, 3, 4, 5 ];
# print(a in list)  # False
# print(a not in list) # True

# a = 20
# b = 10
# c = 15
# d = 5
# e = 0
# e = (a + b) * c / d       #( 30 * 15 ) / 5
# print(e)

# 条件语句
# flag = False
# name = 'xxx'
# if name == 'python':        
#     flag = True             
#     print('111')     
# else:
#     print(name)  
# num = 6
# if num >5 :
#     print('six')
# elif num >5:
#     print('five')
# else:
#     print('end')
# num = 9
# if num > 0 and num < 10 :
#     print("true")
# else:
#     print("false")
# count = 0
# while (count < 9):
#    print(count)
#    count = count + 1
# print ("end !")
# for item in 'python':
#     print(item)
# arr =[1,2,3,4,5,6]
# for item in arr:
#     print(item)

# arr = [[1,2],[3,4],[5,6],[],[7,8]]
# for index,item in enumerate(arr):
#     print(index,"---",item)
#     for c in item:
#         print(c)

# for num in range(0,10):
#     print(num)
#     if num>=5:
#         break
# for num in range(0,10):
#     if num==5:
#         continue
#     print(num)

# for letter in 'Python':
#    if letter == 'h':
#       pass
#       print ('pass')
#    print (letter)
# import  cmath
# import math
# # print(abs(-1))
# # print(math.ceil(5.1))
# print(math.pow( 2, 2 ))
# import random

# print(random.random())

# a = 'xxx'
# print(a*2)

# 列表
from re import A


list1 = ['physics', 'chemistry', 1997, 2000,11,11]
list2 = ['aaa', 'bbb', 1997, 2000]
list3 = [2,1,3,5,7,8,9]
# print(list1[0])
# 删除
# del list1[2]
# print(list1)
# 数组长度
# print(len(list1))
# 数组拼接
# print(list1+list2)
# print(list1[-1])
# print(cmp(list1, list2))
# list1.append(666)
# print(list1)
# print(list1.count(11)) #2
#列表合并
# list1.extend(list2)
# print(list1)
# print(list1.index(1997))
#insert
# list1.insert(1,2333)
# print(list1)
# 删除
# list1.pop(2)
# print(list1)
# list1.remove(2000)
# print(list1)
# list1.reverse()
# print(list1)
# sort
# list3.sort(reverse=True)
# print(list3)
# 元组
d = {
    'name':"zhangsan",
    'age':20,
    'gender':1,
    "address":'xxxxx'
}
# print(d['name'])
# d['age'] = 666
# del d["address"]
# d.clear()
# del d
# print(len(d))
# print(str(d))
# 
# seq=["name",'age',"gerder"]
# d = dict.fromkeys(seq,10)
# print(d)

# import time
# print(time.time())
# print(time.localtime(time.time()))
# print(time.asctime( time.localtime(time.time()) ))
# 格式化成2016-03-20 11:45:39形式
# print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) )
 
# # 格式化成Sat Mar 28 22:24:24 2016形式
# print(time.strftime("%a %b %d %H:%M:%S %Y", time.localtime()) )
  
# # 将格式字符串转换为时间戳
# a = "Sat Mar 28 22:24:24 2016"
# print(time.mktime(time.strptime(a,"%a %b %d %H:%M:%S %Y")))

# import calendar
# cal = calendar.month(2022, 6)
# print(cal)
# import a
# a.print_fun(6666)

# import math
# content = dir(math)
# print(content)
# from tool.c import *

# console(666)
# f = open("a.txt",'w')
# print(f.name) 
# print(f.closed)
# f.close()
# print(f.mode)
# print(f.closed)
# f.write("666")
# f.read()
# import os 
# os.mkdir("file")
# print(os.getcwd())
# def scope_test():
#     def do_local():
#         spam = "local spam"

#     def do_nonlocal():
#         nonlocal spam
#         spam = "nonlocal spam"

#     def do_global():
#         global spam
#         spam = "global spam"

#     spam = "test spam"
#     do_local()
#     print("1.After local assignment:", spam)
#     do_nonlocal()
#     print("2. After nonlocal assignment:", spam)
#     do_global()
#     print("3.After global assignment:", spam)

# scope_test()
# print("4. In global scope:", spam)
# import re
# strs = "1551-2-3-41234"
# num = re.sub(r'\-',"",strs)
# print(num) 
import pymysql
#连接数据库
conn=pymysql.connect(host = '127.0.0.1' # 连接名称，默认127.0.0.1
,user = 'root' # 用户名
,passwd='1qaz2wsx' # 密码
,port= 3306 # 端口，默认为3306
,db='hkzf' # 数据库名称
,charset='utf8' # 字符编码
)
cur = conn.cursor() # 生成游标对象
sql="select * from `users` " # SQL语句
cur.execute(sql) # 执行SQL语句
data = cur.fetchall() # 通过fetchall方法获得数据
for i in data[:2]: # 打印输出前2条数据
    print (i)
cur.close() # 关闭游标
conn.close() # 关闭连接